

/**
 * 异步加载数据
 * @param id：需要异步加载表单数据的表格id
 */
dateView=function(id){
		var $dataView=$("#"+id);
		
		var fields=new Array();
		
		$dataView.find("tbody").remove();
		
		$dataView.find("[field]").each(function(){
			var field=$(this).attr("field");
			fields.push(field);
		})
	
		var url=$dataView.attr("url");
		
		dateParams={};
		
		var html="";
		
		$.ajax({  
		        url:url,  
		        data:dateParams,  
		        type:"post",  
		        dataType:"json",  
		        success:function(data){  
		        	for (var i=0;i<=data.rows.length-1;i++) 
		        	{ 
		        		html+="<tr>"
		        		html+="<td><input type='radio' name='select_edit'/></td>"
		        		for(item in fields)
		        			{
		        			html+="<td field='"+fields[item]+"'>"+data.rows[i][fields[item]]+"</td>";
		        			}
		        		html+="</tr>"
		        	} 
		        	$dataView.append(html);
		        }  
		 });
		
	}

/**
 * 异步提交表单
 * @param formId：表单Id
 * @param modalId：弹出层Id
 * @param dataeViewId：表单提交后要重新加载数据，所以需要dataeViewId
 */
save=function(formId,modalId,dataeViewId){
	var $form = $("#"+formId);
	var $modal = $("#"+modalId);
	var option={
			type:"post",
			dataType:"json",
			success:function(data){
				if(data.success == true)
					{
					$modal.modal("hide");
					dateView(dataeViewId);
					}
			}
	}
	$form.ajaxSubmit(option);
}


tr2form=function($tr,$form){
	var $tds=$tr.find("td");
	$form.clearForm();
	$tds.each(function(){
		var field=$(this).attr("field");
		var text=$(this).html();
		$form.find("[name="+field+"]").attr("value",text);
	})
}






